package Offer2018;

import java.util.Arrays;

/**
 * 形参是基本数据类型
 *  - 传递数据值
 *  实参是引用数据类型
 *  - 传递地址值
 *  - 特殊的类型：String，包装类等对象不可变形
 */
public class MethodParam {

    public static void main(String[] args) {
        int i = 1;
        String str = "hello";
        Integer num = 200;
        int[] arr = {1, 2, 3, 4, 5};
        MyData myData = new MyData();

        change(i,str,num,arr,myData);

        System.out.println(i);//1
        System.out.println(num);//200
        System.out.println(str);//hello
        System.out.println(Arrays.toString(arr));//[2,2,3,4,5]
        System.out.println(myData.a);//11
    }


    public static void change(int i, String str, Integer num, int[] a, MyData myData) {
        i += 1;
        str += "world";
        num += 1;
        a[0] += 1;
        myData.a += 1;

    }
}
class MyData {
    int a = 10;
}
